package slice

import "fmt"

func Slice() {
	arr := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
	arr2 := arr[2:4]
	arr3 := arr[3:4]

	fmt.Println(arr)
	fmt.Println(arr2)
	fmt.Println(arr3)

	arr2[1] = 100
	fmt.Println(arr)
	fmt.Println(arr2)
	fmt.Println(arr3)

}

func Copy() {
	arr := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
	arr2 := []int{100, 101, 102}
	copy(arr[7:9], arr2[1:2])
	fmt.Println(arr)
	fmt.Println(arr2)
}

func Append() {
	arr := make([]int, 10, 20)
	arr = append(arr, 1, 2)
	//arr := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}
	arr2 := arr[0:len(arr)]
	fmt.Println(cap(arr), cap(arr2))
	fmt.Println(arr)
	fmt.Println(arr2)
	arr = append(arr, 11, 22)
	fmt.Println(arr)
	fmt.Println(arr2)
	arr[1] = 100
	fmt.Println(arr)
	fmt.Println(arr2)
}
